867A - Between the Offices - CodeForces Solution


implementation *800

Please click on ads to support us..

Python Code:

n = int(input())
s = input()
SF = 0
FS = 0
for i in range(n - 1):
    if s[i] + s[i + 1] == 'SF':
        SF += 1
    if s[i] + s[i + 1] == 'FS':
        FS += 1
if SF > FS:
    print('YES')
else:
    print('NO')

C++ Code:

#include <bits/stdc++.h>
using namespace std;

int main() {
int n,t;
cin>>n;
string s1;
cin>>s1;
 int count1=0,count2=0;
    for(int i=0; i<n; i++)
{
        if(s1[i] =='S' && s1[i+1] =='F'){
            count1++;
        }
        if(s1[i] =='F' && s1[i+1] =='S'){
            count2++;
        }
 }
    if(count1 > count2){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

1144A - Diverse Strings
1553B - Reverse String
1073A - Diverse Substring
630N - Forecast
312B - Archer
34D - Road Map
630I - Parking Lot
160B - Unlucky Ticket
371B - Fox Dividing Cheese
584B - Kolya and Tanya
137B - Permutation
550C - Divisibility by Eight
5A - Chat Servers Outgoing Traffic
615A - Bulbs
5B - Center Alignment
549A - Face Detection
535B - Tavas and SaDDas
722C - Destroying Array
366A - Dima and Guards
716B - Complete the Word
1461C - Random Events
1627A - Not Shading
141B - Hopscotch
47B - Coins
1466C - Canine poetry
74A - Room Leader
1333D - Challenges in school №41
1475B - New Year's Number
461A - Appleman and Toastman
320B - Ping-Pong (Easy Version)